package com.waya.demo.threadTest;

public class Thread1 extends Thread {

	private static int a = 5;
	private static int b = 0;

	@Override
	public void run() {
		try {
			method();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public  void method() throws Exception {
		synchronized (this) {
//			Thread.sleep(1000);
			if(isTrue(b)) {
				b++;
			}else {
				throw new Exception("错误");
			}
			tt(b);
		}
		
	}
	
	public void tt(int b) {
		System.out.println(Thread.currentThread().getName() + "--------------------------------- " + b);
//		for (int i = 0; i < 1000; i++) {
//			System.out.println(Thread.currentThread().getName() + " " + i);
//		}
	}

	public boolean isTrue(int b) {
		if (a <= b) {
			return false;
		}
		return true;
	}
}
